package com.example.home.adapter

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.home.R
import com.example.home.databinding.ItemHomeCategoryItemCardViewBinding
import com.example.home.entity.discover.CardDataItemData

/**
 * 分类Item的适配器
 * */
class CategoryItemAdapter constructor(layoutId : Int): BaseQuickAdapter<CardDataItemData,BaseViewHolder>(layoutId) {

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<ItemHomeCategoryItemCardViewBinding>(viewHolder.itemView)
    }

    override fun convert(holder: BaseViewHolder, item: CardDataItemData) {
        var dataBinding= holder.getBinding<ItemHomeCategoryItemCardViewBinding>()

        if (item != null && dataBinding!= null){
            dataBinding.viewData=item
            dataBinding.executePendingBindings()
        }
    }

}